home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk1.zip / LST9-15.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  892b  |  39 lines

  1. ;
  2. ; *** Listing 9-15 ***
  3. ;
  4. ; An illustration of the use of SUB AH,AH to convert an
  5. ; array of unsigned byte values between 0 and 7Fh to an
  6. ; array of words. Note that this would work even if Array1
  7. ; contained values greater than 7Fh.
  8. ;
  9.     jmp    Skip
  10. ;
  11. ARRAY_LENGTH    equ    1000
  12. ;
  13. Array1    label    byte
  14. ARRAY_VALUE=0
  15.     rept    ARRAY_LENGTH
  16.     db    ARRAY_VALUE
  17. ARRAY_VALUE=(ARRAY_VALUE+1) and 07fh
  18.                 ;cycle source array byte
  19.                 ; values from 0-7Fh
  20.     endm
  21. ;
  22. Array2    dw    ARRAY_LENGTH dup (?)
  23. ;
  24. Skip:
  25.     mov    si,offset Array1 ;set up array pointers
  26.     mov    di,offset Array2
  27.     mov    ax,ds
  28.     mov    es,ax        ;copy to & from same segment
  29.     cld            ;make string instructions
  30.                 ; increment pointers
  31.     mov    cx,ARRAY_LENGTH
  32.     call    ZTimerOn
  33. ProcessingLoop:
  34.     lodsb            ;get the next element
  35.     sub    ah,ah        ;make it a word
  36.     stosw            ;save the word value
  37.     loop    ProcessingLoop    ;do the next element
  38.     call    ZTimerOff
  39.